package com.drop.android.sdk;

import android.app.Activity;
import android.content.Context;
import android.util.Log;

import com.applovin.sdk.AppLovinMediationProvider;
import com.applovin.sdk.AppLovinPrivacySettings;
import com.applovin.sdk.AppLovinSdk;
import com.applovin.sdk.AppLovinSdkConfiguration;
import com.applovin.sdk.AppLovinSdkInitializationConfiguration;
import com.drop.android.sdk.ad.DropMaxReward;
import com.drop.android.sdk.bridge.DropCocosBridge;
import com.drop.android.sdk.utils.DropAesUtils;

public class SDKManager {

    public static SDKManager getInstance() {
        return InstanceHolder.GAME_APPLICATION;
    }

    private static class InstanceHolder {
        private static final SDKManager GAME_APPLICATION = new SDKManager();
    }


    public void init(Activity activity) {
        Log.e("DROS", "onCreateonCreate");
        Context mApplication = activity.getApplicationContext();
        DropBusiness.init(mApplication);
        DropCocosBridge.getInstance().setMainGameActivity(activity);
    }

    public void interInit() {
        //AppLovinPrivacySettings
        AppLovinPrivacySettings.setHasUserConsent(true);
        AppLovinPrivacySettings.setDoNotSell(false);
        // Create the initialization configuration
        AppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration.builder(
                        DropAesUtils.decrypt(Constant.MAX_KEY, Constant.KEY_FLAG))
                .setMediationProvider(AppLovinMediationProvider.MAX)
                .build();
        // Initialize the SDK with the configuration
        AppLovinSdk.getInstance(DropBusiness.context).initialize(initConfig, new AppLovinSdk.SdkInitializationListener() {
            @Override
            public void onSdkInitialized(final AppLovinSdkConfiguration config) {
//                AppLovinSdk.getInstance(context).showMediationDebugger();
                Log.e("DROS", "onSdkInitialized");
                DropMaxReward.getInstance().loadRewardAd(DropBusiness.context);
            }
        });
    }
}
